#ifndef _OH_CHASSIS_H
#define	_OH_CHASSIS_H
/*******************************************************************************
 **  Name: chassis.h                                                          **
 **  Description:                                                             **
 **                                                                           **
 **  CDDL: Open Source Initiative (OSI) Approved License                      **
 **                                                                           **
 **  Copyright (c) 2009-2010 Barry "Gian" James  <bjames@munixos.net>         **
 **  All rights reserved.                                                     **
 **                                                                           **
 **  The contents of this file are subject to the terms of the CDDL:          **
 **  Common Development and Distribution License (the "License").             **
 **  You may not use this file except in compliance with the License.         **
 **                                                                           **
 **  You can obtain a copy of the license at $PROJECT_ROOT/LICENSE            **
 **  or http://www.opensolaris.org/os/licensing.  This code is Open Source    **
 **  and you are free to use it within the confines of the license, even      **
 **  for your own closed-source commercial projects, as long as you follow    **
 **  the terms set forth in the CDDL.                                         **
 **                                                                           **
 **  When distributing Covered Code, include this CDDL HEADER in each         **
 **  file and include the License file at $PROJECT_ROOT/LICENSE.              **
 **  If applicable, add the following below this CDDL HEADER, with the        **
 **  fields enclosed by brackets "[]" replaced with your own identifying      **
 **  information: Portions Copyright [yyyy] [name of copyright owner]         **
 **                                                                           **
 ******************************************************************************/
// Modified $DateTime$ by $Author$
#define _chassis_h_ID    "$Id$"

#include "component.h"

enum class ChassisLocation
{ larm, rarm, lleg, rleg, lshoulder, rshoulder, ftorso, btorso, cockpit, max };

enum class SuperFrameMaterial { 
    Duraplastic, Alumisteel, Duralloy, Resilium,
    CrystalCarbon, Neovulcanium, MorphicHyposite, StabilizedNonium,
    Megatanium, CrystallizedXanthine, AnnealedSclerosite
};

struct SuperStructure
{
    SuperFrameMaterial  material;
    uint8               hardness;
    uint8               weightFactor;   // material * size = superframe weight
};

//! The SuperStructure is made out of some FrameMaterial and holds components
//! SuperFrame represents a frame location in the Chassis.
class SuperFrame
{
public:
    SuperFrame();
    SuperFrame(ChassisLocation t, uint8 o, uint16 w);

    ChassisLocation  Location(ChassisLocation t = ChassisLocation::max)
        { if (t != ChassisLocation::max) loc = t; return loc; }
    uint8   HardPointsFree() { return hardPoints[0] - hardPoints[1]; }
    uint8   HardPoints() { return hardPoints[0]; }
    uint16  Weight() { return totWeight; }
 
private: 
    ChassisLocation  loc;
    uint8   hardPoints[2];    // for components to be mounted
    uint16  totWeight;      // total weight=SuperFrame.weight + all installed components' weight
    uint16  weight;         // weight of the super structure
    SuperStructure  material;   // what's it made of?

    Component * components;
};

//! This effects your speed and mobility over terrain
enum class Locomotion { biped, tracked, hover, fly, spider };
//! Size effects defense and to hit.
enum class ChassisSize
{ Nano, Micro, Small, Medium, Large, Huge, Colossal, max};

struct ChassisClass
{
    ChassisSize     sz;
    uint8           defMod;
    uint8           attackMod;
    uint8           stealthMod;
    uint8           soakMod;
    uint16          maxArmorMod;
    uint8           maxWeightMod;
    uint8           reach;          // number of squares
    uint8           weightFactor;
};


//! The chassis is the frame + servos,actuators,etc
class Chassis : public Component
{
public:
    Chassis();
    explicit Chassis(const char * c);
    Chassis(const Chassis& orig);
    ~Chassis();

private:
    ChassisClass    size;
    SuperFrame  frame[(int)ChassisLocation::max];
    Locomotion  loco;   // type of movement
    uint8       speed;  // squares per round
    uint16      weightSelf;
    uint16      totWeight;  // including weight of all components
};

#if !defined(__AVR__)
extern const char * ChassisSizeStr[];
extern const char * ChassisLocationStr[];
extern const char * LocomotionStr[];
#endif
#endif	/* _OH_CHASSIS_H */

